package com.scaleit.weighingsystem;

import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;

public class lvProducts extends ListActivity
{
	private String[] TEST_PRODUCTS = new String [] {"Add new product...", "Test Product 1", "Test Product 2", "Test Product 3", "Test Product 4", "Test Product 5"};
	
	@Override
	protected void onCreate(Bundle savedInstanceState) 
	{
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		
		setListAdapter(new ArrayAdapter<String>(this, R.layout.single_item, TEST_PRODUCTS));
		
		ListView list = getListView();
		list.setTextFilterEnabled(true);
		list.setOnItemClickListener(new OnItemClickListener(){

			@Override
			public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
					long arg3) {
				// TODO Auto-generated method stub
				//Toast.makeText(getApplicationContext(),((TextView)arg1).getText(), Toast.LENGTH_LONG).show();
				Intent iAccount = new Intent("com.scaleit.weighingsystem.EDITPRODUCT");
				iAccount.putExtra("PRODUCTNAME", ((TextView)arg1).getText());
				startActivity(iAccount);
			}
			
		});
	}

}
